    #//add by hunter
    #define ALL_REGION

    .section  .text
    .align 2
    .globl pmpSetup
pmpSetup:
    addi sp,sp,-48
	sw s0,44(sp)
    addi s0,sp,48
    # ilm 0x08000000~     DLM 0x20000000~     psram 0x80000000~     NAPOT 8 bytes Region（64bits）
 #ifndef ALL_REGION
    # PMPADDR
    li t0,0x200000D4
    					      # {bit[31:30]}   {bit[29:0]}     {numb of 1 in low bits}   {Address Region of entries,after left shift 2bit}
    csrrs zero, pmpaddr0, t0  # 00  100000000000000000000011010100  0       Region Addr:    0x80000350 ~0x80000357
    li t0,0x200000D6
    csrrs zero, pmpaddr1, t0  # 00 	100000000000000000000011010110  0                       0x80000358 ~0x8000035F
    li t0,0x200000D8
    csrrs zero, pmpaddr2, t0  # 00	100000000000000000000011011000	0                       0x80000360 ~0x80000367
    li t0,0x200000DA
    csrrs zero, pmpaddr3, t0  # 00	100000000000000000000011011010 	0                       0x80000368 ~0x8000036F
    li t0,0x08000000
    csrrs zero, pmpaddr4, t0  # 00	001000000000000000000000000000 	0                       0x20000000 ~0x20000007
    li t0,0x08000002
    csrrs zero, pmpaddr5, t0  # 00 	001000000000000000000000000010 	0                       0x20000008 ~0x2000000F
    li t0,0x08000004
    csrrs zero, pmpaddr6, t0  # 00 	001000000000000000000000000100 	0                       0x20000010 ~0x20000017
    li t0,0x08000006
    csrrs zero, pmpaddr7, t0  # 00 	001000000000000000000000000110 	0                       0x20000018 ~0x2000001F
 #else
    #//add by hunter
    # PMPADDR
    li t0,0x3FFFFFFF
    csrrs zero, pmpaddr0, t0  # 00 111111111111111111111111111111 1(30)            bit[29..0]=1, region: cover all addr size.
 #endif

    #PMPCFG
    #li t0 , 0x1F1F1F1F  #0 00  11 111     0 00  11 111   0  00  11 111  0  00  11 111
                         #L Res A  XWR     L Res A  XWR    L Res A  XWR  L  Res A  XWR
						 # Ok, when memorry access in region; otherwise if outof region, then MCAUSE=0x1,Instruction access fault.
    #li t0 , 0x1F1F1F1B	 # pmp0cfg X disable --- MCAUSE=0x1,Instruction access fault
    #li t0 , 0x1F1F1F1E	 # pmp0cfg Read disable  --- MCAUSE=0x5, Load access fault
    li t0 , 0x1F1F1F1D	 # pmp0cfg Write disable --- MCAUSE=0x7, Store/AMO access fault

    csrw pmpcfg0, t0                      
    li t0 , 0x1F1F1F1F
    csrw pmpcfg1,t0 
   
    lw s0, 44(sp)
	addi sp, sp, 48
	ret
